@import 'wildcard/src/global-styles/breakpoints';

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 12rem;

    :global(.theme-redesign) & {
        @media (--xs-breakpoint-down) {
            background-color: var(--color-bg-1);
            border: 1px solid var(--input-border-color);
            border-radius: var(--border-radius);
            display: inline;
            padding: 0.5rem;
        }
    }

    &__shadow {
        box-shadow: var(--search-input-shadow);
    }

    &__background-container {
        display: flex;
        flex-grow: 1;
        align-items: center;
        border: 1px solid var(--input-border-color);
        border-right-color: transparent;
        border-left-color: transparent;
        background-color: var(--input-bg);
        height: 100%;

        :global(.theme-redesign) & {
            background-color: var(--color-bg-1);

            @media (--xs-breakpoint-down) {
                height: auto;
                border: none;
                display: inline;
            }
        }

        &:first-child {
            border-top-left-radius: 3px;
            border-bottom-left-radius: 3px;
            border-left-color: var(--input-border-color);
        }
    }

    &__focus-container {
        // stylelint-disable-next-line declaration-property-unit-whitelist
        height: calc(100% + 2px); // add 2 pixels for border
        display: flex;
        align-items: center;
        flex: 1 1 auto;
        // stylelint-disable-next-line declaration-property-unit-whitelist
        margin: -1px; // To compensate for the border
        border: 1px solid transparent;
        // Match padding from the regular query input.
        padding-left: 0.75rem;

        &:not(:first-child) {
            padding-left: 0.5rem; // smaller padding if the search context selector is visible
            margin-left: 0.0625rem;
            border-top-left-radius: 0.25rem;
            border-bottom-left-radius: 0.25rem;
        }

        &:focus-within {
            border: 1px solid var(--input-focus-border-color);
            box-shadow: 0 0 0 2px rgba(28, 126, 214, 0.25);
        }

        :global(.theme-redesign) & {
            border-top-left-radius: var(--border-radius);
            border-bottom-left-radius: var(--border-radius);

            @media (--xs-breakpoint-down) {
                height: auto;
                flex-wrap: wrap;
                display: inline;
                padding-left: 0;
                margin-left: 0;

                &:focus-within {
                    border: none;
                    box-shadow: none;
                }
            }
        }
    }

    &__version-context-dropdown {
        :global(.theme-redesign) & {
            @media (--xs-breakpoint-down) {
                display: inline-block;
                vertical-align: middle;
                margin-bottom: 0.5rem;
            }
        }
    }

    &__context-dropdown {
        :global(.theme-redesign) & {
            @media (--xs-breakpoint-down) {
                display: inline-block;
                vertical-align: middle;
                margin-bottom: 0.5rem;
            }
        }
    }

    &__separator {
        // stylelint-disable-next-line declaration-property-unit-whitelist
        width: 1px;
        height: 1.125rem;
        background-color: var(--border-color-2);

        :global(.theme-redesign) & {
            @media (--xs-breakpoint-down) {
                display: none;
            }
        }
    }

    &__input {
        :global(.theme-redesign) & {
            @media (--xs-breakpoint-down) {
                display: inline-block;
                width: 100%;
                border: 1px solid var(--input-border-color);
                border-radius: var(--border-radius);
                padding: 0.375rem 0.5rem;

                &:focus-within,
                &:focus {
                    border: 1px solid var(--input-focus-border-color);
                    box-shadow: 0 0 0 2px rgba(28, 126, 214, 0.25);
                }
            }
        }
    }

    &__toggles {
        padding-right: 0.5rem;
        padding-left: 0.35rem;

        :global(.theme-redesign) & {
            @media (--xs-breakpoint-down) {
                display: inline-flex;
                margin-top: 0.75rem;
                padding-left: 0;
            }
        }
    }

    &__button {
        display: flex;
        :global(.theme-redesign) & {
            @media (--xs-breakpoint-down) {
                display: inline-flex;
                flex-direction: row-reverse;
                margin-top: 0.5rem;
                float: right;
            }
        }
    }
}
